<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui">
<h:head>
	<title>Admin Console | JBoss-Esb-Adaptative</title>
	<h:outputStylesheet library="css" name="layout.css" />
	<script type="text/javascript">
            //<![CDATA[
                function handleMessage(data) {                  
					var info =  data.split(";");
					switch(info[0]){
						case '1':
						  $('#out1').html(info[1]);	
						  $('#img1').attr("src", "/Jboss-Esb-Adaptative-Admin/resources/images/on.png");
						  $('#img2').attr("src", "/Jboss-Esb-Adaptative-Admin/resources/images/off.png");
						  $('#img3').attr("src", "/Jboss-Esb-Adaptative-Admin/resources/images/off.png");						 
						  break;
						case '2':
						  $('#out2').html(info[1]);
						  $('#img1').attr("src", "/Jboss-Esb-Adaptative-Admin/resources/images/off.png");
						  $('#img2').attr("src", "/Jboss-Esb-Adaptative-Admin/resources/images/on.png");
						  $('#img3').attr("src", "/Jboss-Esb-Adaptative-Admin/resources/images/off.png");	
						  break;
						case '3':
						  $('#out3').html(info[1]);
						  $('#img1').attr("src", "/Jboss-Esb-Adaptative-Admin/resources/images/off.png");
						  $('#img2').attr("src", "/Jboss-Esb-Adaptative-Admin/resources/images/off.png");
						  $('#img3').attr("src", "/Jboss-Esb-Adaptative-Admin/resources/images/on.png");	
						  break; 
						default:					
						  break;
					}
                }
            //]]> 
        </script>
</h:head>
<h:body>	
	<div class="entry">		
		<h:form id="form" prependId="false">
			<p:panelGrid columns="3" style="width:100%" styleClass="panel-noborder">
				  <p:panel header="BPS Service" styleClass="serviceInfo panel-noborder">
				  	<h:graphicImage id="img1" url="/resources/images/off.png" />
				  	<br></br>
				  	<h:outputText id="out1" value="#{globalCounter.countBPS}"  />
				  </p:panel>
				  <p:panel header="DGI Service" styleClass="serviceInfo panel-noborder">
				  	<h:graphicImage id="img2" library="images" name="off.png" />
				  	<br></br>
				  	<h:outputText id="out2" value="#{globalCounter.countDGI}" />
				  </p:panel>			  
				  <p:panel header="DNIC Service" styleClass="serviceInfo panel-noborder">
				  	<h:graphicImage id="img3" library="images" name="off.png" />
				  	<br></br>
				  	<h:outputText id="out3" value="#{globalCounter.countDNIC}"  />
				  </p:panel>		
			</p:panelGrid>
			<p:commandButton value="Reset" actionListener="#{globalCounter.reset}" update="form" style="float: right;" />
		</h:form>

		<p:socket onMessage="handleMessage" channel="/counter" />
	</div>
</h:body>
</html>